package cn.boat.router.broker.partition;

import cn.boat.router.broker.Message;
import cn.boat.router.exception.BoatMQException;

import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * 轮询选择器（默认）
 */
public class PollingPartitionSelector extends AbstractPartitionSelector{

    private AtomicInteger atomicInteger = new AtomicInteger(0);

    @Override
    public Partition getPartiton0(String topic, List<Partition> partitions, Message message) throws BoatMQException {
        return partitions.get(atomicInteger.incrementAndGet() % partitions.size());
    }
}
